/*
 * Copyright (c) 2011 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.snj.visangedu.calendar;

import java.io.IOException;

import android.os.AsyncTask;
import android.util.Log;

import com.snj.visangedu.studytime.StudyPlannerFragment;

/**
 * @author AA@google.com (Your Name Here)
 *
 */
public class GC_Modify_Event extends AsyncTask<Void, Void, Void> {

  private static final String TAG = "StudyPlan";

  private com.google.api.services.calendar.model.Event event;
  private String updateID;
  private boolean bReturn = true;

  GC_Modify_Event(com.google.api.services.calendar.model.Event evt, String szID) {
    if (evt != null) event = evt;
    updateID = szID;
  }

  @Override
  protected void onPreExecute() {
  }

  @Override
  protected Void doInBackground(Void... arg0) {
    try {

    	StudyPlannerFragment.Instance.client.events()
          .update(StudyPlannerFragment.Instance.workCalendarInfo.id, updateID, event).execute();

    } catch (IOException e) {
      Log.d(TAG, "> IOException =" + e.getMessage());
      bReturn = false;
    } catch (Exception e) {
      Log.d(TAG, "> update Exception =" + e.getMessage());
      bReturn = false;
    } finally {
    }
    return null;
  }

  @Override
  protected void onPostExecute(Void result) {
    AsyncManager.Instance.WorkProcessComplete("modify event", bReturn);
  }
}
